#include <stdio.h>

// 给定实型变量 X 和整型变量 n 的值，试计算 X+X*X/2!+X*X*X/3!+…+X*X*X*..*X/n!的值

float fun(float, long);
long fac(int);

void main()
{
    int i, n;
    float x, t = 1.0, df = 0.0;
    printf("enter x,n:");
    scanf("%f %d", &x, &n);
    for (i = 1; i <= n; i++)
    {
        t = t * x;
        df += fun(t, fac(i));
    }
    printf("df=%f\n", df);
}

float fun(float y, long m)
{
    float d;
    d = y / m;
    return d;
}

long fac(int x)
{
    long p = 1;
    int j;
    for (j = 1; j <= x; j++)
    {
        p = p * j;
    }
    return p;
}